package com.example.ResumeWorkPlatform.dao;

import java.util.Date;
import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/**
 * @ClassName:WorkResumptioDao
 * @Description: WorkResumptioDao
 * @Author chengwenxing
 * @DateTime 2020-3-31 19:59:45
 */
@Repository
public interface WorkResumptioDao extends JpaRepository<WorkResumptionEntity, Long> {
	/**
	 * 
	 * @param endTime
	 * @param startTime
	 * @Title: getTodayWarning
	 * @Description: 根据园区id获取近七日复工情况
	 * @Author chengwenixng
	 * @Date 2021-03-20 13:35:01
	 * @param startTime
	 * @param endTime
	 * @return
	 */
	@Query(value = "SELECT date(work_resumption_time),COUNT(*) as number  FROM work_resumption_entity WHERE del_flag = TRUE and gerden_entity_id= ?1 AND work_resumption_time BETWEEN ?2 AND ?3 GROUP BY date(work_resumption_time)", nativeQuery = true)
	List<Object[]> findBoardWeekWorkResumptions(Long id, Date startTime, Date endTime);
	/**
	 * 
	 * @Title: TruncateTable
	 * @Description: 
	 * @Author coding
	 * @DateTime 2021-04-23 10:44:19
	 * @return
	 */
	@Transactional
	@Modifying
	@Query(value = "TRUNCATE TABLE work_resumption_entity",nativeQuery = true)
	int TruncateTable();

}
